{include file="public/layout" /}

<body class="bodystyle" style="min-width: auto;">
<div id="toolTipLayer" style="position: absolute; z-index: 9999; display: none; visibility: visible; left: 95px; top: 573px;"></div>
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page ksedit" style="min-width: auto;">
    <form class="form-horizontal" id="post_form" method="post">
        <div class="ncap-form-default">
            <input type="hidden" name="attr_id" value="{$attr_id}" />
            <dl class="row">
                <dt class="tit">
                    <label for="title"><em>*</em>选择关联栏目</label>
                </dt>
                <dd class="opt" style="width: auto;">
                    <select name="typeid" id="typeid" style="width: 300px;" size="22">
                        {$select_html}
                    </select>
                    <span class="err"></span>
                    <p class="notic"></p>
                </dd>
            </dl>
        </div>
    </form>
</div>
<script type="text/javascript">
    $(function () {
        $('#typeid').find('option').click(function(){
            if (!$('#typeid').val()) {
                layer.alert('请选择栏目…！', {icon:5, title:false}, function(index){
                    $('#typeid').val('');
                    layer.close(index);
                });
                return false;
            }

            var parentObj = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引

            layer_loading('正在处理');
            $.ajax({
                url: "{:url('Language/customvar_bind', ['_ajax'=>1])}",
                type: 'POST',
                dataType: 'JSON',
                data: $('#post_form').serialize(),
                success: function(res){
                    layer.closeAll();
                    if (res.code == 1) {
                        parent.layer.msg(res.msg, {shade: 0.3, time: 500}, function(){
                            parent.window.location.reload();
                            parent.layer.close(parentObj);
                        });
                    } else {
                        layer.alert(res.msg, {icon:5, title:false});
                    }
                    return false;
                },
                error: function(e){
                    layer.closeAll();
                    layer.alert('操作失败', {icon:5, title:false});
                    return false;
                }
            });
        });
    });
</script>

{include file="public/footer" /}